package com.qf.controller;

import com.qf.service.ProductEchartsService;
import com.qf.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * --- 万物归集  不随你我 ---
 * <p>
 * 快捷短语
 * main ==  public static void main(String[] args);
 * sout ==  System.out.println();
 *
 * @author shuhan
 * @date 2025/5/6
 * @desc 用于前端展示产品分类数据图表的代码
 */
@RestController
@RequestMapping("/product/echarts")
public class ProductEchartsController {
    @Autowired
    private ProductEchartsService productEchartsService;

    @GetMapping("/getProductCategory")
    public R getProductCategory() {
        List<HashMap<String, Object>> list = productEchartsService.getProductCategory();
        ArrayList<HashMap<String, Object>> map = new ArrayList<>();
        list.forEach(item -> {
            HashMap<String, Object> map1 = new HashMap<>();
            map1.put("name", item.get("name"));
            map1.put("value", item.get("value"));
            map.add(map1);
        });

        return R.ok(map);
    }


}
